import { QuestionActionRecordWithId, Question, CarType, Subject } from "@/types/practice";
import { isDate } from "lodash";

export const getWrongCount = (actionRecordMap: Map<string, QuestionActionRecordWithId>, ids: Question["id"][] = []) => {
  if (ids.length) {
    return ids.filter((id) => actionRecordMap.get(id)?.lastErrorAnswerRecord === false).length;
  }
  return Array.from(actionRecordMap.values()).filter((item) => item.lastErrorAnswerRecord === false).length;
};

export const getCorrectCount = (actionRecordMap: Map<string, QuestionActionRecordWithId>, ids: Question["id"][] = []) => {
  if (ids.length) {
    return ids.filter((id) => actionRecordMap.get(id)?.lastErrorAnswerRecord === true).length;
  }
  return Array.from(actionRecordMap.values()).filter((item) => item.lastErrorAnswerRecord === true).length;
};

export const carTypeMap = {
  [CarType.C1]: "小车",
  [CarType.D]: "摩托车",
  [CarType.A2]: "货车",
  [CarType.A1]: "客车",
  [CarType.C6]: "轻型牵引挂车",
};

export const subjectMap = {
  [Subject.ONE]: "科目一",
  [Subject.FOUR]: "科目四",
};
